// 版权所有 Epic Games, Inc. 保留所有权利。
#pragma once

#include "Abilities/Tasks/AbilityTask.h"

#include "AbilityTask_GrantNearbyInteraction.generated.h"

class UGameplayAbility;
class UObject;
struct FFrame;
struct FGameplayAbilitySpecHandle;
struct FObjectKey;

UCLASS()
class UAbilityTask_GrantNearbyInteraction : public UAbilityTask
{
	GENERATED_UCLASS_BODY()

	virtual void Activate() override;

	/** 等待直到发生重叠。这需要更好地详细说明，以便我们可以指定特定于游戏的碰撞要求 */
	UFUNCTION(BlueprintCallable, Category="Ability|Tasks", meta = (HidePin = "OwningAbility", DefaultToSelf = "OwningAbility", BlueprintInternalUseOnly = "TRUE"))
	static UAbilityTask_GrantNearbyInteraction* GrantAbilitiesForNearbyInteractors(UGameplayAbility* OwningAbility, float InteractionScanRange, float InteractionScanRate);

private:

	virtual void OnDestroy(bool AbilityEnded) override;

	void QueryInteractables(); // 查询可交互对象

	float InteractionScanRange = 100; // 交互扫描范围
	float InteractionScanRate = 0.100; // 交互扫描频率

	FTimerHandle QueryTimerHandle; // 查询定时器句柄

	TMap<FObjectKey, FGameplayAbilitySpecHandle> InteractionAbilityCache; // 交互能力缓存
};